home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-08-16 | 6.7 KB | 228 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: FWDrCmd.h
- // Release Version: $ ODF 1 $
- //
- // Copyright: (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
- //
- // This file contains two command classes that handle Drag-and-Drop.
- // These commands must be subclassed to add Undo support for the following actions:
- // drag-move within a part FW_CDropCommand
- // drag-move to a different part FW_CDropCommand and FW_CDragCommand
- // drag-copy FW_CDropCommand
- //
-
- #ifndef FWDRCMD_H
- #define FWDRCMD_H
-
- #ifndef FWCMD_H
- #include "FWCmd.h"
- #endif
-
- #ifndef FWPASTA_H
- #include "FWPasta.h"
- #endif
-
- #ifndef FWPOINT_H
- #include "FWPoint.h"
- #endif
-
- #ifndef SLREGION_H
- #include "SLRegion.h"
- #endif
-
- // ----- OpenDoc Includes -----
-
- #ifndef FWODTYPS_H
- #include "FWODTyps.h"
- #endif
-
- #ifndef SOM_ODDraft_xh
- #include <Draft.xh>
- #endif
-
- //========================================================================================
- // Forward Declarations
- //========================================================================================
-
- class FW_CPart;
- class FW_CFrame;
- class FW_CSelection;
- class ODFacet;
- class FW_CMouseEvent;
- class ODDragItemIterator;
- class ODDragAndDrop;
-
- //========================================================================================
- // FW_CDragCommand - handles the source side of drag-and-drop
- //========================================================================================
-
- class FW_CDragCommand : public FW_CCommand
- {
- public:
- FW_DECLARE_AUTO(FW_CDragCommand)
-
- public:
- FW_CDragCommand(Environment* ev,
- FW_CFrame* frame,
- FW_Boolean canUndo);
-
- virtual ~ FW_CDragCommand();
-
- //----------------------------------------------------------------------------------------
- // New API
- //
- public:
- void BeginDrag(Environment* ev, const FW_CMouseEvent& theMouseEvent);
- // Called by frame's Drag method
-
- FW_Boolean IsDragMoveToAnotherPart(Environment*) const
- {return fDragMoveToAnotherPart;}
- // return TRUE if this was a drag-move to another part.
-
- //----------------------------------------------------------------------------------------
- // Inherited API (From FW_CCommand)
- //
- public:
- virtual void DoIt(Environment* ev); // Override
- // Don't override.
- // To make drag-move to another part Undo-able, override these methods:
- // UndoIt, RedoIt, SaveUndoState, DoClear
-
- virtual void CommitDone(Environment* ev);
- // Called just before the command is deleted.
- // doneState values are kODDone or kODRedone (ODTypes.h)
- // Default calls FreeUndoState if it's a drag-move to another part
-
- protected:
- virtual ODShape* CreateDragShape(Environment* ev, ODFacet* facet);
-
- void AbortTransaction(Environment* ev);
- // Clean up the Undo stack if the Drag&Drop operation failed
-
- //----------------------------------------------------------------------------------------
- // Data Members
- //
- protected:
- ODDropResult fDragResult;
- FW_CSelection* fSelection;
-
- private:
- FW_Boolean fBeganTransaction; // remember that we added an ODBeginAction
- FW_Boolean fDragMoveToAnotherPart;
-
- };
-
- //========================================================================================
- // FW_CDropCommand - handles the destination side of drag-and-drop
- //========================================================================================
-
- class FW_CDropCommand : public FW_CCommand, public FW_MPasteAsHandler
- {
- public:
- FW_DECLARE_AUTO(FW_CDropCommand)
-
- public:
- FW_CDropCommand(Environment* ev,
- FW_CFrame* frame,
- ODDragItemIterator* dropInfo,
- ODFacet* facet,
- const FW_CPoint& dropPoint,
- FW_Boolean canUndo);
-
- virtual ~ FW_CDropCommand();
-
- //----------------------------------------------------------------------------------------
- // Inherited API (From FW_CCommand)
- //
- virtual void DoIt(Environment* ev); // Override
- // Don't override.
- // To make this command Undo-able, override these methods:
- // UndoIt, RedoIt, SaveRedoState, DoDrop, DoDroppedInSameFrame
-
- virtual void CommitUndone(Environment* ev);
- // Called just before the command is deleted.
- // doneState value is kODUndone (ODTypes.h)
- // Default calls FreeRedoState if it's not a drag-move within the frame
-
- //----------------------------------------------------------------------------------------
- // New API
- //
- public:
- ODDropResult GetDropResult(Environment* ev) const;
-
- protected:
-
- // ----- Called after
- virtual FW_Boolean DoDrop(Environment* ev,
- ODStorageUnit* dropSU,
- const FW_CPoint& mouseDownOffset,
- const FW_CPoint& dropPoint,
- FW_Boolean isDropMove,
- short itemNumber);
- virtual FW_Boolean DoDroppedInSameFrame(Environment* ev,
- ODStorageUnit* dropSU,
- const FW_CPoint& mouseDownOffset,
- const FW_CPoint& dropPoint);
- virtual void DoDroppedPasteAs(Environment* ev,
- const FW_CPoint& mouseDownOffset,
- const FW_CPoint& dropPoint);
-
- FW_Boolean IsDragMoveInSameFrame(Environment* ev) const;
- ODFacet* GetDropFacet(Environment* ev) const;
-
- //----------------------------------------------------------------------------------------
- // Internal API
- //
- public:
- ODDropResult PrivHandleDrop(Environment* ev);
-
- protected:
- FW_CPoint PrivReadMouseDownOffset(Environment* ev, ODStorageUnit *dropSU) const;
-
- //----------------------------------------------------------------------------------------
- // Data Members
- //
- protected:
- ODDropResult fDropResult;
- FW_CSelection* fSelection;
-
- private:
- FW_Boolean fDroppedInSameFrame;
- ODFacet* fFacet;
- ODDragItemIterator* fDropItemIterator;
- FW_CPoint fDropPoint; // In content coordinates
- };
-
- //========================================================================================
- // FW_CDropCommand inlines
- //========================================================================================
-
- //--------------------------------------------------------------------
- // FW_CDropCommand::GetDropFacet
- //--------------------------------------------------------------------
- inline ODFacet* FW_CDropCommand::GetDropFacet(Environment*) const
- {
- return fFacet;
- }
-
- //--------------------------------------------------------------------
- // FW_CDropCommand::GetDropResult
- //--------------------------------------------------------------------
- inline ODDropResult FW_CDropCommand::GetDropResult(Environment*) const
- {
- return fDropResult;
- }
-
- //--------------------------------------------------------------------
- // FW_CDropCommand::IsDragMoveInSameFrame
- //--------------------------------------------------------------------
- inline FW_Boolean FW_CDropCommand::IsDragMoveInSameFrame(Environment*) const
- {
- return (fDroppedInSameFrame && fDropResult == kODDropMove);
- }
-
- #endif
-